//
//  Builder.m
//  ArchitectDemo
//
//  Created by 姚胜龙 on 2017/7/5.
//  Copyright © 2017年 姚胜龙. All rights reserved.
//

#import "Builder.h"


@interface Builder ()

@property (nonatomic, strong) BuilderParams *params;

@end

@implementation Builder

- (void)dealloc {
    NSLog(@"Builder销毁了");
}

- (instancetype)initWithContext:(UIViewController *)context
{
    self = [super init];
    if (self) {
        self.params = [[BuilderParams alloc] initWithContext:context];
    }
    return self;
}

- (Builder *)setTitle:(NSString *)title {
    self.params.title = title;
    return self;
}

- (Builder *)setMessage:(NSString *)message {
    self.params.message = message;
    return self;
}
- (Builder *)setConfirmTitle:(NSString *)confirmTitle {
    self.params.confirmTitle = confirmTitle;
    return self;
}
- (Builder *)setCancelTitle:(NSString *)cancelTitle {
    self.params.cancelTitle = cancelTitle;
    return self;
}

- (Builder *)setCancelHandler:(void (^)(UIAlertAction * _Nullable))handler {
    self.params.cancelHandler = handler;
    return self;
}

- (Builder *)setConfirmHandler:(void (^)(UIAlertAction * _Nullable))handler {
    self.params.confirmHandler = handler;
    return self;
}

//构建方法
- (SLAlertController *)build {
    return [[SLAlertController alloc] initWithParams:self.params];
}

@end
